import axios from "axios";
const instance = axios.create({
    baseURL: '/api'
})
// 请求拦截器
instance.interceptors.request.use(config => {
    config.headers['x-auth-token'] = localStorage.getItem('x-auth-token');
    return config;
}, err => {
    return Promise.reject(err);
})
// 响应拦截器
instance.interceptors.response.use(response => {
    if (response.data.code !== 0 && response.data.code !== 400 && response.data.code !== 407) {
        alert(response.data.message || response.data.msg);
        return;
    }
    return response.data;
}, err => {
    return Promise.reject(err);
})
export default instance;